import tensorflow as tf
import numpy as np


def generator_distinguish(model_name, char_image_width, char_image_height):
    """
    创建一个识别单个字符的成器，该生成器可以不断识别单个字符
    """
    saver = tf.train.import_meta_graph(model_name + '.meta')
    with tf.Session() as sess:
        saver.restore(sess, model_name)
        eucd = None
        while True:
            img1, img2 = yield eucd
            eucd = sess.run('eucd:0', feed_dict={
                'img1:0': np.reshape(img1, [1, char_image_width * char_image_height]),
                'img2:0':np.reshape(img2, [1, char_image_width * char_image_height]),
            })

